﻿$(function(){
	$("#menu li a").wrapInner( '<span class="out"></span>' );		
		$("#menu li a").each(function() {
			$( '<span class="over">' +  $(this).text() + '</span>' ).appendTo( this );
		});
		$("#menu li a").hover(function() {
			$(".out",	this).stop().animate({'top':	'46px'},	200); // move down - hide
			$(".over",	this).stop().animate({'top':	'0px'},		200); // move down - show
		}, function() {
			$(".out",	this).stop().animate({'top':	'0px'},		200); // move up - show
			$(".over",	this).stop().animate({'top':	'-46px'},	200); // move up - hide
	});

	var num = 0;
	//$("#banner_player").hide();
	$("#banner_player ul li img").load(function(){
		num++;
		if (num==4)
		{
			$("#banner_player").show();
		}
	}).click(function(){	
		//如果已经处于active状态，return
		if (this.className.indexOf("active")!=-1) return;	
		//正文文字渐隐
		//$("#frontText").fadeOut();
		//$("#frontTextBack").fadeOut();
		$("#frontTextSub").fadeOut();
		//active状态的图片恢复原样
		$("li img.active").fadeTo(200,0.6)
		.removeClass("active")
		.animate({top:5,width:52,left:80},300)
		.parent().css({"color":"#aaa"});  //	
		//获取数据
		var i = $(this).attr("pic");
		//var t = $(this).attr("text").split("|");	
		var t = $(this).attr("text");
		//当前
		$(this).animate({top:-5,width:70,height:40,left:60},100)
		.addClass("active")
		.fadeTo(200,1)
		.parent().css({"color":"white"});
		$("#back").children().addClass("gray").end().fadeTo(500,0.1,function(){
			//var IMG = new Image();
			//IMG.s
			$(this).children("img").attr("src","pic/"+i+".jpg").removeClass("gray");	  //更改图片
			$(this).fadeTo(500,1,function(){
				//$("#frontText").html(t[0]).fadeIn(200);	//更改正文文字
				//$("#frontTextBack").html(t[0]).fadeIn(200);	//阴影文字
				$("#frontTextSub").html(t).fadeIn(200)}	//副标题
				);
			})
		})

	//初始第一张图片
	var i =0;
	show();
	function show(){
		if (i==$("#banner_player ul li img").size()) i = 0
		$("#banner_player ul li img").eq(i).click();
		i++;
		//setTimeout(show(),1000);
	}
	//document.oncontextmenu   =  function(e){return false}	
	if (self.location.search!=""){
		var V = self.location.search;
		V = V.substr(1,V.length);
		eval(V);
		var json ="{";
		if (option.skin==0)
			$("#mask").hide();
		if (option.animate == 0){
		$("#banner_player ul").hide();
		}
		$("#banner_player").width(option.width?option.width:960);
		$("#banner_player").height(option.height?option.height:260);
		$("#back img").width($("#banner_player").width());
		$("#back img").height($("#banner_player").height());
		$(self.parent.document.getElementById("splash")).children().height($("#banner_player").height()).width($("#banner_player").width());
	}	
});

function AddFavorite(sURL, sTitle) {      //收藏
    try {
        window.external.addFavorite(sURL, sTitle);
    }
    catch (e) {
        try {
            window.sidebar.addPanel(sTitle, sURL, "");
        }
        catch (e) {
            alert("加入收藏失败，请使用Ctrl+D进行添加");
        }
    }
}